<?php
/*
 *---------------------------------------------------------------------------
 *
 *                  T E N C E N T   P R O P R I E T A R Y
 *
 *     COPYRIGHT (c)  2008 BY  TENCENT  CORPORATION.  ALL RIGHTS
 *     RESERVED.   NO  PART  OF THIS PROGRAM  OR  PUBLICATION  MAY
 *     BE  REPRODUCED,   TRANSMITTED,   TRANSCRIBED,   STORED  IN  A
 *     RETRIEVAL SYSTEM, OR TRANSLATED INTO ANY LANGUAGE OR COMPUTER
 *     LANGUAGE IN ANY FORM OR BY ANY MEANS, ELECTRONIC, MECHANICAL,
 *     MAGNETIC,  OPTICAL,  CHEMICAL, MANUAL, OR OTHERWISE,  WITHOUT
 *     THE PRIOR WRITTEN PERMISSION OF :
 *
 *                        TENCENT  CORPORATION
 *
 *       Advertising Platform R&D Team, Advertising Platform & Products
 *       Tencent Ltd.
 *---------------------------------------------------------------------------
 */

/**

 */
class JYModel {
    public $tableName;
    public $pkey;
    public $dbAlias = 'default';
    
	function execute($sql,$dbAlias = ""){
		if(!$dbAlias) $dbAlias = $this->dbAlias;
		return DBBase::getInstance($dbAlias)->execute($sql);
	}

	function query($sql,$dbAlias = ""){
		if(!$dbAlias) $dbAlias = $this->dbAlias;
		return DBBase::getInstance($dbAlias)->query($sql);
	}

	function find($where,$fields='*',$order='',$dbAlias = ""){
		if(!$dbAlias) $dbAlias = $this->dbAlias;
		return DBBase::getInstance($dbAlias)->find($this->tableName,$where,$fields,$order);
	}

	function findAll($where='',$fields='*',$order='', $page = 0, $pageSize = 10,&$totalCount=0,$dbAlias = ""){
		if(!$dbAlias) $dbAlias = $this->dbAlias;
		return DBBase::getInstance($dbAlias)->findAll($this->tableName,$where,$fields,$order, $page, $pageSize ,&$totalCount);
	}

	function update($table,$where,$row,$dbAlias = ""){
		if(!$dbAlias) $dbAlias = $this->dbAlias;
		return DBBase::getInstance($dbAlias)->update($this->tableName,$where,$row);
	}

	function create($table,$row,$dbAlias = ""){
		if(!$dbAlias) $dbAlias = $this->dbAlias;
		return DBBase::getInstance($dbAlias)->create($this->tableName,$row);
	}

	function del($where,$dbAlias = ""){
		if(!$dbAlias) $dbAlias = $this->dbAlias;
		return DBBase::getInstance($dbAlias)->del($this->tableName,$where);
	}
}